package org.jeecg.modules.demo.extend.extend.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.demo.extend.entity.BdMaterial;
import org.jeecg.modules.demo.extend.service.IBdMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author zhongll1
 * @ClassName MaterialExtendController
 * @Description 物料扩展接口
 * @date 2024/3/8 14:59
 * @Version 1.0
 */
@Api(tags="物料基本信息")
@RestController
@RequestMapping("/extend/bdMaterial")
@Slf4j
public class MaterialExtendController extends JeecgController<BdMaterial, IBdMaterialService> {
    @Autowired
    private IBdMaterialService bdMaterialService;

    /**
     * 根据物料分类id分页列表查询
     *
     * @param bdMaterial
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    //@AutoLog(value = "物料基本信息-根据物料分类id分页列表查询")
    @ApiOperation(value="物料基本信息-根据物料分类id分页列表查询", notes="物料基本信息-根据物料分类id分页列表查询")
    @GetMapping(value = "/queryByMarbasclassId")
    public Result<IPage<BdMaterial>> queryPageList(BdMaterial bdMaterial,
                                                   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                                   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                                   @RequestParam(name="id") String id,
                                                   HttpServletRequest req) {
        QueryWrapper<BdMaterial> queryWrapper = new QueryWrapper<>();
        Page<BdMaterial> page = new Page<BdMaterial>(pageNo, pageSize);
        queryWrapper.lambda().eq(BdMaterial::getMarbasclassId,id);

        IPage<BdMaterial> pageList = bdMaterialService.page(page, queryWrapper);
        return Result.OK(pageList);
    }
}
